#ifndef LOG
#define LOG
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<log4cpp/PatternLayout.hh>
#include<log4cpp/FileAppender.hh>
#include<log4cpp/OstreamAppender.hh>
#include<log4cpp/RollingFileAppender.hh>
#include<log4cpp/Priority.hh>
#include<log4cpp/Category.hh>
#include<limits>
using namespace log4cpp;

class Mylogger
{
public:
     static void warn(const char* msg);
     static void error(const char* msg);
     static void debug(const char* msg);
     static void info(const char* msg);
     static Mylogger* getInstance();
     static void destory();
     static void changeDegree( Priority::Value  value);

private:
     Mylogger();
     Mylogger& operator=(const Mylogger& rhs)=delete;
     Mylogger(const Mylogger& rhs)=delete;
     ~Mylogger();

     static Mylogger*_p;
     Appender* _pos;
     PatternLayout* _ptn;
     static Category& _cate;
};
#define LogInfo(msg) {\
    string newmsg(string(__FILE__)+" " +std::to_string(__LINE__)+" " +__func__ +" "+msg);\
    Mylogger::getInstance()->info(newmsg.c_str());\
}

#define LogERROR(msg) {\
    string newmsg(string(__FILE__)+" " +std::to_string(__LINE__)+" " +__func__ +" "+msg);\
    Mylogger::getInstance()->info(newmsg.c_str());\
}
#define LogDebug(msg) {\
    string newmsg(string(__FILE__)+" " +std::to_string(__LINE__)+" " +__func__ +" "+msg);\
    Mylogger::getInstance()->info(newmsg.c_str());\
}
#define LogWarn(msg) {\
    //string加的过程中要保证每次加完都是string类型或者至少前两个加完是string
    string newmsg(/*string(__FILE__)+*/" " +std::to_string(__LINE__)+" " +__func__ +" "+msg);\
    Mylogger::getInstance()->info(newmsg.c_str());\
}
//可以用append进行1拼接，不用生成临时string对象
#endif
